// TODO: CODE REVIEW & CLEANUP!
//
// MediaControl.xaml.cs
//

using System;
using System.Windows.Controls;
using HomeUX.ClientAppSupport;
using HomeUX.MusicClientLibrary;

namespace HomeUX.ClientApp
{

public partial class MediaControl : UserControl
{
    public const string MusicDeviceName = "Music Server";

    public MediaControl()
    {
        InitializeComponent();
        Loaded += MediaControl_Loaded;
    }

    void MediaControl_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        TheTouchTabStrip_SelectedItemDataChanged(null, null);
    }

    private void TheTouchTabStrip_SelectedItemDataChanged(object sender, EventArgs e)
    {
        TheTouchTabStrip.ManageTabSheet(TheTiVoControl, TheXboxControl, TheMusicControl, TheDvdControl, TheVcrControl);
    }

    private void TheMusicControl_BrowseArtistsButtonClick(object sender, EventArgs e)
    {
        ClientFramework.Current.GoToScreen(String.Format("{0} Library", MusicDeviceName), null);
    }

    private void TheMusicControl_SearchButtonClick(object sender, EventArgs e)
    {
        ClientFramework.Current.GoToScreen(String.Format("{0} Search", MusicDeviceName), null);
    }

    private void TheMusicControl_ViewThisArtistButtonClick(object sender, EventArgs e)
    {
        string artistName = TheMusicControl.CurrentArtistName;
        if (!String.IsNullOrEmpty(artistName))
        {
            Screen screen;
            MusicArtistScreen screenControl;
            ClientFramework.Current.FindScreen(String.Format("{0} Artist", MusicDeviceName), out screen, out screenControl);
            screenControl.ArtistName = artistName;
            screen.GoTo();
        }
    }

    private void TheMusicControl_ViewThisAlbumButtonClick(object sender, EventArgs e)
    {
        string albumId = TheMusicControl.CurrentAlbumId;
        if (albumId != null)
        {
            Screen screen;
            MusicAlbumScreen screenControl;
            ClientFramework.Current.FindScreen(String.Format("{0} Album", MusicDeviceName), out screen, out screenControl);
            screenControl.AlbumId = albumId;
            screenControl.HighlightTrackNumber = -1;
            screen.GoTo();
        }
    }

    private void TheMusicControl_ViewNowPlayingButtonClick(object sender, EventArgs e)
    {
        // this button is hidden due to the mode that the MusicController control is in
    }

    private void TheMusicControl_ViewQueueButtonClick(object sender, EventArgs e)
    {
        ClientFramework.Current.GoToScreen(String.Format("{0} Queue", MusicDeviceName), null);
    }
}

}
